Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-tappable
Advanced tools
Tappable component for React. Abstracts touch events to implement onTap
, onPress
, and pinch events.
The events mimic their native equivalents as closely as possible:
Tappable
) has -active
or -inactive
added to it to enable pressed-state stylingonPress
property is set, it will cancel the touch event after the press happensWhen touch events are not supported, it will fall back to mouse events. Keyboard events are also supported, emulating the behaviour of native button controls.
Live demo: jedwatson.github.io/react-tappable
To build the examples locally, run:
npm install
gulp dev
Then open localhost:8000
in a browser.
The easiest way to use React-tappable is to install it from npm.
npm install react-tappable --save
Ensure to include it in your own React build process (using Browserify, etc).
You could also use the standalone build by including dist/react-tappable.js
in your page; but, if you do this, make sure you have already included React, and that it is available globally.
React-tappable generates a React component (defaults to <span>
) and binds touch events to it.
To disable default event handling (e.g. scrolling) set the preventDefault
prop.
import Tappable from 'react-tappable';
<Tappable onTap={this.handleTapEvent}>Tap me</Tappable>
For a lighter component, you can opt-in to just the features you need:
import Tappable from 'react-tappable/lib/Tappable';
import Pinchable from 'react-tappable/lib/Pinchable';
import TapAndPinchable from 'react-tappable/lib/TapAndPinchable';
<Tappable onTap={this.handleTapEvent}>I respond to Tap events</Tappable>
<Pinchable onPinch={this.handlePinch}>I respond to Pinch events</Pinchable>
<TapAndPinchable onTap={this.handleTapEvent} onPinch={this.handlePinch}>In respond to both!</TapAndPinchable>
The TapAndPinchable
component is the default one you get when you just import react-tappable
.
activeDelay
ms delay before the -active
class is added, defaults to 0
component
component to render, defaults to 'span'
classes
optional object containing active
and inactive
class names to apply to the component; useful with css-modulesclassBase
base to use for the active/inactive classesclassName
optional class name for the componentmoveThreshold
px to allow movement before cancelling a tap; defaults to 100
pressDelay
ms delay before a press event is detected, defaults to 1000
pressMoveThreshold
px to allow movement before ignoring long presses; defaults to 5
preventDefault
(boolean) automatically call preventDefault on all eventsstopPropagation
(boolean) automatically call stopPropagation on all eventsstyle
(object) styles to apply to the componentThese are the special events implemented by Tappable
.
onTap
fired when touchStart or mouseDown is followed by touchEnd or mouseUp within the moveThresholdonPress
fired when a touch is held for the specified msonPinchStart
fired when two fingers land on the screenonPinchMove
fired on any movement while two fingers are on screenonPinchEnd
fired when less than two fingers are left on the screen, onTouchStart is triggerred, if one touch remainsPinch events come with a special object with additional data to actually be more useful than the native events:
touches
: Array of Objects - {identifier, pageX, pageY} - raw data from the eventcenter
: Object - {x, y} - Calculated center between the two touch pointsangle
: Degrees - angle of the line connecting the two touch points to the X-axisdistance
: Number of pixels - beween the two touch pointsdisplacement
: Object {x, y} - offset of the center since the pinch begandisplacementVelocity
: Object {x, y} : Pixels/ms - Immediate velocity of the displacementrotation
: degrees - delta rotation since the beginning of the gesturerotationVelocity
: degrees/millisecond - immediate rotational velocityzoom
: Number - Zoom factor - ratio between distance between the two touch points now over initialzoomVelocity
: zoomFactor/millisecond - immediate velocity of zoomingtime
: milliseconds since epoch - TimestampThe following native event handlers can also be specified.
onKeyDown
onKeyUp
onTouchStart
onTouchMove
onTouchEnd
onMouseDown
onMouseUp
onMouseMove
onMouseOut
Returning false
from onKeyDown
, onMouseDown
, or onTouchStart
handlers will prevent Tappable
from handling the event.
See CHANGES.md
Copyright (c) 2017 Jed Watson. MIT
FAQs
Touch / Tappable Event Handling Component for React
The npm package react-tappable receives a total of 2,130 weekly downloads. As such, react-tappable popularity was classified as popular.
We found that react-tappable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.